import { AxiosResponse } from "axios";
import { JxtechTreeResult, OrgUnitTreeNode } from "@whjxtech/jxtech-component";
import service from "@/api";
import { SERVICE_CONFIG } from "../_base";

const baseUrl = SERVICE_CONFIG.ORG + "/org/tree";

export type StationTreeTreeNode = {
  canClick: boolean;
  deptId: string;
  superStationId: string;
};

/**获取部门树 */
export function orgUnitTree(queryparam?: any): Promise<AxiosResponse<JxtechTreeResult<OrgUnitTreeNode>[]>> {
  var url = baseUrl + "/unitTree";
  return service.get(url, { params: queryparam });
}

/**
 * 获取api权限树
 * @param queryparam 查询参数
 */
export function orgApiTree(queryparam?: any): Promise<AxiosResponse<JxtechTreeResult<OrgUnitTreeNode>[]>> {
  var url = baseUrl + "/apiTree";
  return service.get(url, { params: queryparam });
}

/**
 * 岗位树
 * @param queryparam 查询参数
 * @returns
 */
export function stationTree(queryparam?: any): Promise<AxiosResponse<JxtechTreeResult<StationTreeTreeNode>[]>> {
  var url = baseUrl + "/stationTree";
  return service.get(url, { params: queryparam });
}
